# Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) # Permission to use, copy, modify, and distribute this material # for any purpose and without fee is hereby granted, provided # that the above copyright notice and this permission notice # appear in all copies, and that the name of Bellcore not be # used in advertising or publicity pertaining to this # material without the specific, prior written permission # of an authorized representative of Bellcore. BELLCORE # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY # OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. # Conversion from C shell to Bourne shell by Z-Code Software Corp. # Conversion Copyright (c) 1992 Z-Code Software Corp. # Permission to use, copy, modify, and distribute this material # for any purpose and without fee is hereby granted, provided # that the above copyright notice and this permission notice # appear in all copies, and that the name of Z-Code Software not # be used in advertising or publicity pertaining to this # material without the specific, prior written permission # of an authorized representative of Z-Code. Z-CODE SOFTWARE # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY # OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. if [ -z "$METAMAIL_TMPDIR" ] then METAMAIL_TMPDIR=/tmp MustDelete=0 batchmode=0 splitsize=100000 while test ! -z "$*" case $1 in -S) shift if test -z "$*" then echo "-S requires a following argument, the SPLIT threshhold" exit 1 fi splitsize=$1 shift ;; -b) batchmode=1 shift ;; -c) shift if test -z "$*" then echo "-c requires a following argument, the CC address" exit 1 fi cc=$1 shift ;; -s) shift if test -z "$*" then echo "-s requires a following argument, the SUBJECT" exit 1 fi subject=$1 shift ;; -t) shift if test -z "$*" then echo "-t requires a following argument, the TO address" exit 1 fi to=$1 shift ;; -e) shift if test -z "$*" then echo "-e requires a following argument, the ENCODING value" exit 1 fi encode=$1 shift ;; -f) shift if test -z "$*" then echo "-f requires a following argument, the DATA FILE" exit 1 fi datafile=$1 shift ;; -m) shift if test -z "$*" then echo "-m requires a following argument, the MIME CONTENT-TYPE" exit 1 fi ctype=$1 shift ;; -z) MustDelete=1 shift ;; *) echo UNRECOGNIZED METASEND OPTION: $1 exit 1 ;; esac if test $batchmode -eq 0 if test -z "${to:-}" then echo-n "To: " read to if test -z "${subject:-}" then echo-n "Subject: " read subject if test -z "${cc:-}" then echo-n "CC: " read cc if test -z "${ctype:-}" then echo-n "Content-type: " read ctype if test -z "${datafile:-}" then looping=1 while test $looping -eq 1 echo-n "Name of file containing $ctype data: " read datafile if test -r "$datafile" then looping=0 else echo "The file $datafile does not exist." fi done if test -z "${encode:-}" then looping=1 while test $looping -eq 1 echo "Do you want to encode this data for sending through the mail?" echo " 1 -- No, it is already in 7 bit ASCII" echo " 2 -- Yes, encode in base64 (most efficient)" echo " 3 -- Yes, encode in quoted-printable (less efficient, more readable)" echo " 4 -- Yes, encode it using uuencode (not standard, being phased out)" read encode looping=0 case "$encode" in 1) encodingprog=cat encode=7bit ;; 2) encodingprog="mimencode -b" encode=base64 ;; 3) encodingprog="mimencode -q" encode=quoted-printable ;; 4) encodingprog="uuencode $datafile" encode=x-uue ;; *) echo Unrecognized answer, please try again. looping=1 ;; esac done if test -z "${to:-}" \ -o -z "${subject:-}" \ -o -z "${ctype:-}" \ -o -z "${datafile:-}" then echo "metasend: in batch mode, -t, -s, -f, and -m are all required" exit 1 if test ! -r "$datafile" then echo "metasend: The file $datafile does not exist" exit 1 if test -z "${cc:-}" then cc='' if test -z "${encode:-}" then case "$ctype" in text*) encodingprog="mimencode -q" encode=quoted-printable ;; *) encodingprog="mimencode -b" encode=base64 ;; esac else case "$encode" in base64) encodingprog="mimencode -b" ;; x-uue) encodingprog="uuencode $datafile" ;; *) encodingprog="mimencode -q" encode=quoted-printable ;; esac fname=$METAMAIL_TMPDIR/metasend.$$ echo "To: $to" > $fname echo "Subject: $subject" >> $fname echo "CC: $cc" >> $fname echo "MIME-Version: 1.0" >> $fname echo "Content-type: $ctype" >> $fname echo "Content-Transfer-Encoding: $encode" >> $fname echo "" >> $fname "$encodingprog" < "$datafile" >> "$fname" # Ensure last line has trailing carriage return echo "" >> "$fname" splitmail -s $splitsize -d $fname if test $? -eq 0 rm -f $fname elif test "$MustDelete" -eq 1 echo Mail delivery failed rm -f $fname echo "Mail delivery failed, draft mail is in $fname"